package com.wat.ext;

import com.wat.config.AppConfig;
import com.wat.service.Impl.OrderServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ExtMain {

	public static void main(String[] args) {
		// 生命周期测试
		BeanLifeCycleTest();
	}


	/**
	 * FactoryBean 接口测试
	 *
	 * 类地址：com.wat.ext.OrderFactoryBean
	 */
	public static void FactoryBeanTest(){
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

		Object order = context.getBean("getUserFactoryBean");
		System.out.println(order.toString());
		System.out.println(order.getClass().toString());

		Object userFactory = context.getBean("&getUserFactoryBean");
		System.out.println(userFactory.getClass().toString());
	}

	/**
	 * bean 生命周期测试
	 *
	 * 类地址：com.wat.ext.BeanLifecycle
	 */
	public static void BeanLifeCycleTest(){
//		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		ClassPathXmlApplicationContext context =
				new ClassPathXmlApplicationContext("${wat:classpath:application.xml}");
		OrderServiceImpl orderServiceImpl = context.getBean(OrderServiceImpl.class);
//		context.destroy();
	}
}
